package com.bt.lms.ui.page.stu;

import com.bt.lms.ui.action.registration.stu.PageImportStuInfoSelectFileTFAction;
import com.bt.lms.ui.action.registration.stu.PageImportsStuInfoCloseBtnAction;
import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;

/**
 * 批量导入报名信息界面
 */
public class PageImportsStuInfo extends VBox {

    /**
     * 批量导入报名信息界面长
     */
    private double preWidth = 1280;
    /**
     * 批量导入报名信息界面高
     */
    private double preHeight = 1000;

    /**
     * 标签默认长度
     */
    private double labDefaultWidth = 200;

    public PageImportsStuInfo(){

        this.setPrefSize(preWidth,preHeight);
        this.setPadding(new Insets(5));
        this.setSpacing(20);

        //顶部横向盒子
        HBox topHBox = new HBox();
        initTopHBox(topHBox);
        //批量导入报名信息横向盒子
        HBox importsStuInfoHBox = new HBox();
        initEnrollStuInfoHBox(importsStuInfoHBox);
        //所属学习中心横向盒子
        HBox learningCenHBox = new HBox();
        initLearningCenHBox(learningCenHBox);
        //所属招生计划横向盒子
        HBox ofEnPHBox = new HBox();
        initOfEnPHBox(ofEnPHBox);
        //选择导入文件横向盒子
        HBox importFileHBox = new HBox();
        initImportFileHBox(importFileHBox);
        //数据校检验结果横向盒子
        HBox dataResultHBox = new HBox();
        initDataResultHBox(dataResultHBox);
        //底部横向盒子
        HBox bottomHBox = new HBox();
        initBottomHBox(bottomHBox);


        ObservableList<Node> children = this.getChildren();
        children.addAll(topHBox,importsStuInfoHBox,learningCenHBox,ofEnPHBox,importFileHBox,dataResultHBox,bottomHBox);

    }



    /**
     * 底部横向盒子
     * @param bottomHBox
     */
    private void initBottomHBox(HBox bottomHBox) {
        bottomHBox.setPadding(new Insets(0,10,0,50));
        bottomHBox.setSpacing(20);
        bottomHBox.setAlignment(Pos.CENTER);
        //关闭按钮
        Button closeBtn = new Button("关闭");
        BtnStyle.cancelBtn(closeBtn);
        //保存按钮
        Button saveBtn = new Button("保存");
        BtnStyle.saveBtn(saveBtn);
        //保存按钮事件
        PageImportsStuInfoCloseBtnAction pageImportsStuInfoSaveBtnAction = new PageImportsStuInfoCloseBtnAction();
        saveBtn.setOnAction(pageImportsStuInfoSaveBtnAction);
        saveBtn.setCursor(Cursor.HAND);
//        pageImportsStuInfoSaveBtnAction.PageImportsStuInfo(this);
        //关闭按钮事件
        PageImportsStuInfoCloseBtnAction pageImportsStuInfoCloseBtnAction = new PageImportsStuInfoCloseBtnAction();
        closeBtn.setOnAction(pageImportsStuInfoCloseBtnAction);
        closeBtn.setCursor(Cursor.HAND);
        ObservableList<Node> children = bottomHBox.getChildren();
        children.addAll(saveBtn,closeBtn);
    }

    /*
     * 数据校校验结果横向盒子
     * @param dataResultHBox
     */
    private void initDataResultHBox(HBox dataResultHBox) {
        dataResultHBox.setPadding(new Insets(0,10,0,50));
        dataResultHBox.setSpacing(20);
        //数据校验结果标签
        Label dataResultLab = new Label("数据校验结果");
        dataResultLab.setPrefWidth(labDefaultWidth);//标签默认长度
        dataResultLab.setFont(Font.font(null,FontWeight.BOLD,null,20));
        //数据校验结果文本域
        TextArea dataResultTA = new TextArea();
        dataResultTA.setId("dataResultTA");
        ObservableList<Node> children = dataResultHBox.getChildren();
        children.addAll(dataResultLab,dataResultTA);

    }

    /**
     * 选择导入文件横向盒子
     * @param importFileHBox
     */
    private void initImportFileHBox(HBox importFileHBox) {
        importFileHBox.setPadding(new Insets(0,10,0,50));
        importFileHBox.setSpacing(20);
        //选择导入文件标签
        Label selectFileLab = new Label("选择导入文件");
        selectFileLab.setPrefWidth(labDefaultWidth);//标签默认长度
        selectFileLab.setFont(Font.font(null,FontWeight.BOLD,null,20));
        //选择文件文本框
        TextField selectFileTF = new TextField();
        selectFileTF.setPromptText("点击选择文件");
        selectFileTF.setId("selectFileTF");
        //上传按钮
        Button uploadBtn = new Button("上传");
        BtnStyle.cancelBtn(uploadBtn);
        uploadBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                uploadBtn.setCursor(Cursor.HAND);
            }
        });

        ObservableList<Node> children = importFileHBox.getChildren();
        children.addAll(selectFileLab,selectFileTF,uploadBtn);
        //文本框点击事件
        PageImportStuInfoSelectFileTFAction pageImportStuInfoSelectFileTFAction = new PageImportStuInfoSelectFileTFAction();
        selectFileTF.setOnMouseClicked(pageImportStuInfoSelectFileTFAction);
    }

    /**
     * 所属招生计划横向盒子
     *
     * @param ofEnPHBox
     */
    private void initOfEnPHBox(HBox ofEnPHBox) {
        ofEnPHBox.setPadding(new Insets(0,10,0,50));
        ofEnPHBox.setSpacing(20);
        //所属招生计划标签
        Label ofEnPLab = new Label("选择所属招生计划*");
        ofEnPLab.setPrefWidth(labDefaultWidth);//标签默认长度
        ofEnPLab.setFont(Font.font(null,FontWeight.BOLD,null,20));
        //所属招生计划文本框
        TextField ofEnpTF = new TextField();
        ofEnpTF.setId("ofEnpTF");
        //选择招生计划按钮
        Button ofEnpBtn = new Button("选择招生计划");
        ofEnpBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                ofEnpBtn.setCursor(Cursor.HAND);
            }
        });
        BtnStyle.cancelBtn(ofEnpBtn);
        ObservableList<Node> children = ofEnPHBox.getChildren();
        children.addAll(ofEnPLab,ofEnpTF,ofEnpBtn);
    }

    /**
     * 选择所属学习中心横向盒子
     * @param learningCenHBox
     */
    private void initLearningCenHBox(HBox learningCenHBox) {
        learningCenHBox.setPadding(new Insets(0,10,0,50));
        learningCenHBox.setSpacing(20);

        //所属学习中心标签
        Label learningCenLab = new Label("选择所属学习中心*");
        learningCenLab.setPrefWidth(labDefaultWidth);//标签默认长度
        learningCenLab.setFont(Font.font(null,FontWeight.BOLD,null,20));

        //所属招生计划文本框
        TextField learningCenTF = new TextField();
        learningCenTF.setId("learningCenTF");
        //选择学习中心按钮
        Button learningCenBtn = new Button("选择学习中心");
        BtnStyle.cancelBtn(learningCenBtn);
        learningCenBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                learningCenBtn.setCursor(Cursor.HAND);
            }
        });

        learningCenHBox.getChildren().addAll(learningCenLab,learningCenTF,learningCenBtn);
    }

    /**
     * 批量导入报名信息横向盒子
     * @param importsStuInfoHBox
     */
    private void initEnrollStuInfoHBox(HBox importsStuInfoHBox) {
        importsStuInfoHBox.setPadding(new Insets(2));
        //批量导入报名信息标签
        Label importsStuInfoLab = new Label("批量导入报名信息");
        //设置字体大小
        importsStuInfoLab.setFont(Font.font(null, FontWeight.BOLD,null,22));
        importsStuInfoLab.setTextFill(Color.rgb(198,0,1));//字体颜色
        importsStuInfoHBox.getChildren().addAll(importsStuInfoLab);

    }

    /**
     * 顶部横向盒子
     * @param topHBox
     */
    private void initTopHBox(HBox topHBox) {
        topHBox.setSpacing(20);
        topHBox.setPadding(new Insets(2));
        //顶部标签
        Label topLab = new Label("当前位置：🏠>招生管理>报名学员管理>批量导入报名信息");
        topLab.setFont(new Font(20));//设置字体大小
        ObservableList<Node> children = topHBox.getChildren();
        children.addAll(topLab);
    }
}
